<template>
  <div>
    <h1>cart 模块测试</h1>
    <button @click="add">触发cart_m中的mutations中的方法</button>
    <button @click="addminmging">触发cart_m中的Actions中的方法</button>
  </div>
</template>

<script>
import { mapState, mapGetters, mapMutations, mapActions } from "vuex";
export default {
  mounted() {
    //   获取moudles中模块中的state的值
    console.log(this.$store.state.cart_m.goods.name);
    console.log(this.$store.state.users_m.name);
    console.log(this);
    console.log(this.$store.getters["cart_m/priceNumEO"]);
  },
  computed: {
    //   vuex最外层的state当中的值获取方式
    // 对于模块中的state的值使用mapState获取时，
    ...mapState("cart_m", ["goods"]),
    ...mapState("users_m", ["name"]),
    ...mapState(["name", "num"]),

    // vuex最外层的getters当中的值获取
    ...mapGetters(["evenOrOdd"]),
    // 对于模块中的getter的值使用mapGetters获取时，
    ...mapGetters("cart_m", ["priceNumEO"]),
  },
  methods: {
    ...mapMutations("cart_m", ["addOnePriceNum"]),
    ...mapActions("cart_m", ["mingming"]),
    add() {
      //   this.$store.commit("cart_m/addOnePriceNum");
      this.addOnePriceNum();
    },
    addminmging() {
      /*  this.$store.dispatch("cart_m/mingming", { sex: "男" }); */
      this.mingming({ sex: "男" });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>